package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzbqTagcategories;
import com.ruoyi.system.service.IDzbqTagcategoriesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 标签分类Controller
 * 
 * @author tianxingxia
 * @date 2025-02-08
 */
@RestController
@RequestMapping("/system/tagcategories")
public class DzbqTagcategoriesController extends BaseController
{
    @Autowired
    private IDzbqTagcategoriesService dzbqTagcategoriesService;

    /**
     * 查询标签分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:tagcategories:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzbqTagcategories dzbqTagcategories)
    {
        startPage();
        List<DzbqTagcategories> list = dzbqTagcategoriesService.selectDzbqTagcategoriesList(dzbqTagcategories);
        return getDataTable(list);
    }

    /**
     * 导出标签分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:tagcategories:export')")
    @Log(title = "标签分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzbqTagcategories dzbqTagcategories)
    {
        List<DzbqTagcategories> list = dzbqTagcategoriesService.selectDzbqTagcategoriesList(dzbqTagcategories);
        ExcelUtil<DzbqTagcategories> util = new ExcelUtil<DzbqTagcategories>(DzbqTagcategories.class);
        util.exportExcel(response, list, "标签分类数据");
    }

    /**
     * 获取标签分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tagcategories:query')")
    @GetMapping(value = "/{tagCategoryId}")
    public AjaxResult getInfo(@PathVariable("tagCategoryId") Long tagCategoryId)
    {
        return success(dzbqTagcategoriesService.selectDzbqTagcategoriesByTagCategoryId(tagCategoryId));
    }

    /**
     * 新增标签分类
     */
    @PreAuthorize("@ss.hasPermi('system:tagcategories:add')")
    @Log(title = "标签分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzbqTagcategories dzbqTagcategories)
    {
        return toAjax(dzbqTagcategoriesService.insertDzbqTagcategories(dzbqTagcategories));
    }

    /**
     * 修改标签分类
     */
    @PreAuthorize("@ss.hasPermi('system:tagcategories:edit')")
    @Log(title = "标签分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzbqTagcategories dzbqTagcategories)
    {
        return toAjax(dzbqTagcategoriesService.updateDzbqTagcategories(dzbqTagcategories));
    }

    /**
     * 删除标签分类
     */
    @PreAuthorize("@ss.hasPermi('system:tagcategories:remove')")
    @Log(title = "标签分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagCategoryIds}")
    public AjaxResult remove(@PathVariable Long[] tagCategoryIds)
    {
        return toAjax(dzbqTagcategoriesService.deleteDzbqTagcategoriesByTagCategoryIds(tagCategoryIds));
    }
}
